package com.online.controller;

import com.online.dal.dao.UserDAO;
import com.online.dal.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserDAO userDAO;

    @RequestMapping(value = "", method = RequestMethod.GET)
    public ModelAndView indexOfAll() throws Exception {
        ModelAndView mv = new ModelAndView("user");
        List<User> userList = userDAO.queryByModel(new User());
        mv.addObject("userList", userList);
        return mv;
    }
}
